cmake_minimum_required(VERSION 2.6)
project (Program)

SET (Program_SOURCES aliHLTTRDrun.cxx rec-hlt-trd.cxx createFileList.cxx rec-hlt-trd-digits.cxx)

FOREACH(cxxfile ${Program_SOURCES})
	STRING(REPLACE ".cxx" ".h" hfile ${cxxfile})
	SET ( Program_HEADERS ${Program_HEADERS} ${hfile})
ENDFOREACH(cxxfile)
MESSAGE("[i] Headers: ${Program_HEADERS}")
MESSAGE("[i] ROOTSYS set: $ENV{ROOTSYS}")
MESSAGE("[i] ALICE_ROOT set: $ENV{ALICE_ROOT}")
MESSAGE("[i] ALICE_TARGET set: $ENV{ALICE_TARGET}")

SET (ALIROOTINCLUDES $ENV{ALICE_ROOT}/include)

EXECUTE_PROCESS ( COMMAND root-config --cflags WORKING_DIRECTORY /tmp OUTPUT_VARIABLE ROOTCFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE )
MESSAGE("[i] ROOTCFLAGS set ${ROOTCFLAGS} ")
EXECUTE_PROCESS ( COMMAND root-config --incdir WORKING_DIRECTORY /tmp OUTPUT_VARIABLE ROOTINCLUDES OUTPUT_STRIP_TRAILING_WHITESPACE )
MESSAGE("[i] ROOTINCLUDES is ${ROOTINCLUDES} ")

EXECUTE_PROCESS ( COMMAND root-config --libdir WORKING_DIRECTORY /tmp OUTPUT_VARIABLE ROOTLIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE )
MESSAGE("[i] ROOTLIBDIR set ${ROOTLIBDIR} ")

INCLUDE_DIRECTORIES (${ROOTINCLUDES})
INCLUDE_DIRECTORIES (${ALIROOTINCLUDES})
INCLUDE_DIRECTORIES ($ENV{ALICE_ROOT}/STEER)
INCLUDE_DIRECTORIES ($ENV{ALICE_ROOT}/TPC)
INCLUDE_DIRECTORIES ($ENV{ALICE_ROOT}/TRD)
INCLUDE_DIRECTORIES ($ENV{ALICE_ROOT}/HLT)
INCLUDE_DIRECTORIES ($ENV{ALICE_ROOT}/HLT/TRD)
INCLUDE_DIRECTORIES ($ENV{ALICE_ROOT}/HLT/BASE)

#SET(CMAKE_CXX_FLAGS "${ROOTCFLAGS}")
#SET(CMAKE_CPP_FLAGS "${ROOTCFLAGS}")
SET(CMAKE_LD_FLAGS "-g ${ROOTLIBS}" )

#       Specify directories in which to search for libraries.
# Make sure the linker can find the library once it is built.
SET ( ALILIBDIR $ENV{ALICE_ROOT}/lib/tgt_$ENV{ALICE_TARGET})
#SET ( ALIHLTLIBDIR $ENV{ALIHLT_LIBDIR})
LINK_DIRECTORIES (${ROOTLIBDIR} ${ALILIBDIR})
MESSAGE ("[i] ALILIBDIR is ${ALILIBDIR}")
#MESSAGE ("[i] ALIHLTLIBDIR is ${ALIHLTLIBDIR}")

SET (ROOTLIBLINK dl Core Cint RIO Net Hist Graf Graf3d Gpad Tree Rint Postscript Matrix Physics MathCore freetype Gui VMC EG Geom Minuit XMLParser XMLIO)
SET (ROOTLIBLINK ${ROOTLIBLINK} MLP Proof Thread ProofPlayer TreePlayer)
SET (ALILIBLINK STEERBase STEER CDB ESD AliHLTTRD RAWDatabase RAWDatarec TRDbase TRDrec HLTbase AliHLTGlobal AliHLTUtil AOD TRDbase TPCrec TPCbase PHOSUtils STAT)
SET (ALILIBLINK ${ALILIBLINK} MUONbase MUONmapping MUONcalib MUONtrigger MUONgeometry MUONraw MUONcore RAWDatasim)

#--------------- EXECS
add_executable (aliHLTTRDrun aliHLTTRDrun.cxx)
TARGET_LINK_LIBRARIES(aliHLTTRDrun ${ROOTLIBLINK} ${ALILIBLINK})

add_executable (rec-hlt-trd rec-hlt-trd.cxx)
TARGET_LINK_LIBRARIES(rec-hlt-trd ${ROOTLIBLINK} ${ALILIBLINK})

add_executable (rec-hlt-trd-digits rec-hlt-trd-digits.cxx)
TARGET_LINK_LIBRARIES(rec-hlt-trd-digits ${ROOTLIBLINK} ${ALILIBLINK})
